package com.ryskoo.controller.product;

import com.ryskoo.catering.producttag.domain.ProductTagPO;
import com.ryskoo.catering.producttag.service.IProductTagService;
import com.ryskoo.customer.vendor.service.IVendorService;
import com.ryskoo.framework.core.controller.BasicHandler;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;


/**
 * 商品标签管理
 *
 * @author JackHou
 *
 */
@Controller("caterProductTagController")
@RequestMapping("/vendor/cater/producttag")
public class ProductTagController extends BasicHandler<ProductTagPO> {

    private static final String TEMPLATE_PATH = "system/producttag";

    private static final String MODULE_NAME = "ProductTag";
    /**
     * 基类构造方法.
     */
    public ProductTagController() {
        super(TEMPLATE_PATH, MODULE_NAME);
    }

    private IProductTagService productTagService;

    @Autowired
    private IVendorService vendorConsumer;

    @Autowired
    public void setService(IVendorService vendorConsumer) {
        this.vendorConsumer = vendorConsumer;
        super.setService(vendorConsumer);
    }

    /*@Override
    protected void buildListPageData(Model model, HttpServletRequest request) {
        List<VendorDTO> list = new ArrayList<>();
        ReturnMessageDTO<List<VendorDTO>> returnMessageDTO = vendorConsumer.getAll();
        if(returnMessageDTO.getReturnCode()==ReturnCodeEnum.SUCCESS.getReturnCode()){
            list = returnMessageDTO.getReturnMessage();
        }
        model.addAttribute("vendorList",list);
        super.buildListPageData(model, request);
    }*/

    /**
     * 重写添加标签方法，设置所属商户名称
     * @param dto
     *            新增的对象 {@link ProductTagDTO}
     * @return
     */
    /*@Override
    public ReturnMessageDTO add(@RequestBody ProductTagDTO dto) {
        String vendorUuid = dto.getVendorUuid();
        ReturnMessageDTO<VendorDTO> returnMessageDTO = vendorConsumer.getById(vendorUuid);
        if(returnMessageDTO.getReturnCode()==ReturnCodeEnum.SUCCESS.getReturnCode()){
            VendorDTO vendorDTO = returnMessageDTO.getReturnMessage();
            String vendorName = vendorDTO.getVendorName();
            dto.setVendorName(vendorName);
        }
        return super.add(dto);
    }*/
}
